package jdl.databaseObjects.datatypes.sqlite;

import jdl.databaseObjects.DbType;
import jdl.databaseObjects.DbTypeUnknownException;
import jdl.databaseObjects.sqlite.datatypes.BigintDbType;
import jdl.databaseObjects.sqlite.datatypes.IntDbType;
import jdl.databaseObjects.sqlite.datatypes.IntegerDbType;
import jdl.databaseObjects.sqlite.datatypes.VarcharDbType;

public class SqliteDbTypeFactory {
	private SqliteDbTypeFactory() {

	}

	public static DbType createIntDbType() {
		return new IntDbType();
	}

	public static DbType createVarcharDbType(int size) {
		return new VarcharDbType(size);
	}

	public static DbType createBigintDbType() {
		return new BigintDbType();
	}

	public static DbType createIntegerDbType() {
		return new IntegerDbType();
	}

	public static DbType fromString(String typeAsString)
			throws DbTypeUnknownException {
		if (typeAsString.contains("varchar"))
			return VarcharDbType.fromString(typeAsString);
		if (typeAsString.compareToIgnoreCase("bigint") == 0)
			return createBigintDbType();
		if (typeAsString.compareToIgnoreCase("integer") == 0)
			return createIntegerDbType();
		if (typeAsString.compareToIgnoreCase("int") == 0)
			return createIntDbType();
		throw new DbTypeUnknownException();
	}
}
